<%@page import="pojo.Account"%>
<%@page import="pojo.Category"%>
<%@page import="pojo.Manufacturer"%>
<%@page import="pojo.Product"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<!-- Navigation -->
<div class="navigation">
    Navigation: <span class="current">Home</span>
</div> 
<!-- Left Content -->
<div class="left_content">
    <!-- Categories -->
    <div class="title_box">Loại Sản Phẩm</div>
    <ul class="left_menu">
        <c:forEach items = "${CATEGORY_LIST}" var = "p" varStatus="status">
            <c:choose>
                <c:when test="status % 2 ==0">
                    <li class="even"><a href="/trangchu.htm?view=danhsachsanpham&cat=${p.getId()}&page=1&item=21">${p.getName()}</a></li>
                </c:when>
                <c:otherwise>
                    <li class="odd"><a href="/trangchu.htm?view=danhsachsanpham&cat=${p.getId()}&page=1&item=21">${p.getName()}</a></li>
                </c:otherwise>
            </c:choose>
        </c:forEach> 
    </ul>   

    <!-- Manufactures -->
    <div class="title_box">Nhà Cung Cấp</div>
    <ul class="left_menu">
        <c:forEach items = "${MANUFACTURER_LIST}" var = "p" varStatus="status">
            <c:choose>
                <c:when test="status % 2 ==0">
                    <li class="even"><a href="/trangchu.htm?view=danhsachsanpham&manu=${p.getId()}&page=1&item=21">${p.getName()}</a></li>
                </c:when>
                <c:otherwise>
                    <li class="odd"><a href="/trangchu.htm?view=danhsachsanpham&manu=${p.getId()}&page=1&item=21">${p.getName()}</a></li>
                </c:otherwise>
            </c:choose>
        </c:forEach> 
    </ul>     
    <!-- Banner -->
    <div class="banner_adds">
        <a href="#"><img src="Style/Home/images/bann2.jpg" alt="" title="" border="0" /></a>
    </div>   
</div>

<!-- Center Content -->
<div class="center_content">
    <c:choose>
        <c:when test="${MESSAGE != 'PRODUCT_NOT_EXIST'}">
            <div class="Product_Name">
                ${PRODUCT.getName()}
            </div>
            <div class="Product_Main">
                <div class ="ProductImage">
                    <img src="${PRODUCT.getImage()}" alt="" title="" border="0" width="300px"/></div>
                <div class ="Product_Info">
                    <div class = "Product_Line">
                        <h1>Loại sản phẩm</h1>
                    </div>
                    <div class = "Product_Line">
                        ${CATEGORY_DAO.getCategory(PRODUCT.getCategory().getId()).getName()}
                    </div>
                    <div class = "Product_Line">
                        <h1>Xuất xứ</h1>
                    </div>
                    <div class = "Product_Line">
                        ${PRODUCT.getOrigin()}
                    </div>
                    <div class = "Product_Line">
                        <h1>Nhà sản xuất</h1>
                    </div>
                    <div class = "Product_Line">
                        ${MANUFACTURER_DAO.getManufacturer(PRODUCT.getManufacturer().getId()).getName()}
                    </div>
                    <div class="Product_Price">
                        ${PRODUCT.getUnitPrice()}VNĐ
                    </div>
                    <div class="Product_Buy">
                    </div>
                </div>
            </div>
            <div class="Product_Description">
                ${PRODUCT.getDescription()}
            </div>
        </c:when>
        <c:otherwise>
            <div class="Product_Name">
                Sản phẩm không tồn tại.
            </div>
        </c:otherwise>
    </c:choose>
</div>

<!-- Right Content -->
<div class="right_content">
    <!-- Shopping cart -->
    <div class="shopping_cart">
        <div class="cart_title">Shopping cart</div>
        <div class="cart_details">
            3 items <br />
            <span class="border_cart"></span>
            Total: <span class="price">350$</span>
        </div>
        <div class="cart_icon">
            <a href="#" title="header=[Checkout] body=[&nbsp;]"><img src="Style/Home/images/shoppingcart.png" alt="Checkout" /></a>
        </div>
    </div>

    <!-- Special Products -->
    <div class="title_box">Sản phẩm cùng loại</div>  
    <c:forEach items = "${PRODUCT_LIST}" var = "p" varStatus="status">
        <div class="border_box">
            <div class="product_title"><a href="/trangchu.htm?view=sanpham&id=${p.getId()}">${p.getName()}</a></div>
            <div class="product_img"><a href="/trangchu.htm?view=sanpham&id=${p.getId()}"><img src="${p.getImage()}" alt="" title="" border="0" width="130px"/></a></div>
            <div class="prod_price"> <span class="price">${p.getUnitPrice()} VNĐ</span></div>

        </div>  
    </c:forEach> 


    <!-- Banner -->
    <div class="banner_adds">
        <a href="#"><img src="Style/Home/images/bann1.jpg" alt="" title="" border="0" /></a>
    </div>  
</div>
<script type="text/javascript" src="Script/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(document).ready(function(){ 
        $(".warning_box").hide();
        $('.valid_box').hide();
        $('.error_box').hide();
        var a = "${MESSAGE}";
        if(a == "PAGE_NOT_FOUND")
        {
            $('.error_box').html("Không tìm thấy trang này.");
            $(".error_box").show("slow");
        }   
        if(a == "PAGE_EMPTY")
        {
            $('.warning_box').html("Không có sản phẩm nào trong dữ liệu.");
            $(".warning_box").show("slow");
        }           
        if(a == "PRODUCT_DELETE_SUCCESS")
        {
            $('.valid_box').html("Đã xóa thành công sản phẩm.");
            $(".valid_box").show("slow");
        } 
        if(a == "PRODUCT_NOT_EXIST")
        {
            $('.error_box').html("Không tìm thấy sản phẩm cần xóa.");
            $(".error_box").show("slow");
        } 
        if(a == "PRODUCT_DELETED")
        {
            $('.warning_box').html("Sản phẩm cần xóa đã bị xóa.");
            $(".warning_box").show("slow");
        }   
    })	
</script>

